package com.forever7776.life.core.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.forever7776.life.core.entity.Follow;
import com.forever7776.life.core.mapper.FollowMapper;
import com.forever7776.life.core.service.IFollowService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户关注表 服务实现类
 * </p>
 *
 * @author kz
 * @since 2018-02-11
 */
@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow> implements IFollowService {

    /**
     * 查询关注列表
     *
     * @param page
     * @param userId
     * @param searchUserId
     * @return
     */
    @Override
    public Page<Follow> selectAll(Page<Follow> page, String userId, String searchUserId) {
        EntityWrapper<Follow> ew = new EntityWrapper<>();
        ew.eq("user_id", userId);
        if (StringUtils.isNotEmpty(searchUserId)) {
            ew.eq("follow_user_id", searchUserId);
        }
        return selectPage(page, ew);
    }
}
